package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AlwtDayreport;
import com.ruoyi.system.service.IAlwtDayreportService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日报格Controller
 * 
 * @author ruoyi
 * @date 2025-03-17
 */
@Controller
@RequestMapping("/system/dayreport")
public class AlwtDayreportController extends BaseController
{
    private String prefix = "system/dayreport";

    @Autowired
    private IAlwtDayreportService alwtDayreportService;


    @GetMapping()
    public String dayreport()
    {
        return prefix + "/dayreport";
    }

    /**
     * 查询日报格列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AlwtDayreport alwtDayreport)
    {
        startPage();
        List<AlwtDayreport> list = alwtDayreportService.selectAlwtDayreportList(alwtDayreport);
        return getDataTable(list);
    }

    /**
     * 导出日报格列表
     */

    @Log(title = "日报格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AlwtDayreport alwtDayreport)
    {
        List<AlwtDayreport> list = alwtDayreportService.selectAlwtDayreportList(alwtDayreport);
        ExcelUtil<AlwtDayreport> util = new ExcelUtil<AlwtDayreport>(AlwtDayreport.class);
        return util.exportExcel(list, "日报格数据");
    }

    /**
     * 新增日报格
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存日报格
     */

    @Log(title = "日报格", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AlwtDayreport alwtDayreport)
    {
        return toAjax(alwtDayreportService.insertAlwtDayreport(alwtDayreport));
    }

    /**
     * 修改日报格
     */

    @GetMapping("/edit/{dayId}")
    public String edit(@PathVariable("dayId") Long dayId, ModelMap mmap)
    {
        AlwtDayreport alwtDayreport = alwtDayreportService.selectAlwtDayreportByDayId(dayId);
        mmap.put("alwtDayreport", alwtDayreport);
        return prefix + "/edit";
    }

    /**
     * 修改保存日报格
     */

    @Log(title = "日报格", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AlwtDayreport alwtDayreport)
    {
        return toAjax(alwtDayreportService.updateAlwtDayreport(alwtDayreport));
    }

    /**
     * 删除日报格
     */

    @Log(title = "日报格", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(alwtDayreportService.deleteAlwtDayreportByDayIds(ids));
    }
}
